import React, { useState, useMemo } from "react";
import { Button } from "antd";

export default function TestUseMemo() {
    const [count, setCount] = useState(0);
    const [title, setTitle] = useState(new Date().toLocaleString());
    return (
        <>
            {count}
            <Button onClick={() => setCount(count + 1)}>修改count</Button>
            <Button onClick={() => setTitle(new Date().toLocaleString())}>修改title</Button>
            <Child title={title} />
        </>
    );
}
function Child({ title }) {
    const renderTitle = useMemo(() => {
        console.log("执行了renderTitle");
        return <div>加工后的title：{title}</div>;
    }, [title]);
    return <div>{renderTitle}</div>;
}
